Ext.define('Seq.form.field.Password', {
    extend: 'Seq.form.field.Text',
    xtype: 'xpassword',

    name: 'password',
    algorithm: 'sha256',
    allowBlank: false,

    maxLength: 20,
    hideLabel: true,
    inputType: 'password',
    vtype: undefined, // 允许输入特殊字符
    emptyText: '登录密码',
    blankText: '密码不能为空',

    triggers: {
        glyphed: {
            cls: 'text-eye-trigger',
            handler(object, trigger) {
                var input = Ext.get(object.getId() + '-inputEl');
                if ('password' == object.inputType) {
                    object.inputType = 'text';
                    trigger.getEl().removeCls('text-eye-trigger');
                    trigger.getEl().addCls('text-eye-trigger-hover');
                } else {
                    object.inputType = 'password';
                    trigger.getEl().removeCls('text-eye-trigger-hover');
                    trigger.getEl().addCls('text-eye-trigger');
                }
                input.set({
                    type: object.inputType
                });
            }
        }
    },

    getSubmitValue() {
        var value = this.callParent();
        switch (this.algorithm) {
            case 'sha256' :
                return Seq.data.Sha.sha256(value);
            default :
                return value;
        }
    }
});
